<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>3-10（2）打印三角形</title>
</head>
<body>
<script>
  var str="";
  var level=prompt("请输入三角形的行数");
  for(i=1;i<=level;i++){
    var star=i*2-1;

    for(var j=0;j<star;++j){
      str+="*";
    }
    str+="\n";
  }
  alert(str);
</script>
</body>
</html>